package com.ruoyi.system.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.CarGroupPurchaseMapper;
import com.ruoyi.system.domain.CarGroupPurchase;
import com.ruoyi.system.service.ICarGroupPurchaseService;

/**
 * 优惠团购Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-08-06
 */
@Service
public class CarGroupPurchaseServiceImpl implements ICarGroupPurchaseService 
{
    @Autowired
    private CarGroupPurchaseMapper carGroupPurchaseMapper;

    /**
     * 查询优惠团购
     * 
     * @param id 优惠团购主键
     * @return 优惠团购
     */
    @Override
    public CarGroupPurchase selectCarGroupPurchaseById(Long id)
    {
        return carGroupPurchaseMapper.selectCarGroupPurchaseById(id);
    }

    /**
     * 查询优惠团购列表
     * 
     * @param carGroupPurchase 优惠团购
     * @return 优惠团购
     */
    @Override
    public List<CarGroupPurchase> selectCarGroupPurchaseList(CarGroupPurchase carGroupPurchase)
    {
        return carGroupPurchaseMapper.selectCarGroupPurchaseList(carGroupPurchase);
    }

    /**
     * 新增优惠团购
     * 
     * @param carGroupPurchase 优惠团购
     * @return 结果
     */
    @Override
    public int insertCarGroupPurchase(CarGroupPurchase carGroupPurchase)
    {
        return carGroupPurchaseMapper.insertCarGroupPurchase(carGroupPurchase);
    }

    /**
     * 修改优惠团购
     * 
     * @param carGroupPurchase 优惠团购
     * @return 结果
     */
    @Override
    public int updateCarGroupPurchase(CarGroupPurchase carGroupPurchase)
    {
        return carGroupPurchaseMapper.updateCarGroupPurchase(carGroupPurchase);
    }

    /**
     * 批量删除优惠团购
     * 
     * @param ids 需要删除的优惠团购主键
     * @return 结果
     */
    @Override
    public int deleteCarGroupPurchaseByIds(Long[] ids)
    {
        return carGroupPurchaseMapper.deleteCarGroupPurchaseByIds(ids);
    }

    /**
     * 删除优惠团购信息
     * 
     * @param id 优惠团购主键
     * @return 结果
     */
    @Override
    public int deleteCarGroupPurchaseById(Long id)
    {
        return carGroupPurchaseMapper.deleteCarGroupPurchaseById(id);
    }

    /**
     * 上架优惠团购
     * 
     * @param id 优惠团购主键
     * @return 结果
     */
    @Override
    public int shelfUpCarGroupPurchase(Long id)
    {
        CarGroupPurchase carGroupPurchase = new CarGroupPurchase();
        carGroupPurchase.setId(id);
        carGroupPurchase.setStatus(1L); // 1表示上架状态
        return carGroupPurchaseMapper.updateCarGroupPurchase(carGroupPurchase);
    }

    /**
     * 下架优惠团购
     * 
     * @param id 优惠团购主键
     * @return 结果
     */
    @Override
    public int shelfDownCarGroupPurchase(Long id)
    {
        CarGroupPurchase carGroupPurchase = new CarGroupPurchase();
        carGroupPurchase.setId(id);
        carGroupPurchase.setStatus(5L); // 5表示活动已下架状态
        return carGroupPurchaseMapper.updateCarGroupPurchase(carGroupPurchase);
    }

    @Override
    public List<CarGroupPurchase> listPurchaseByMerchantId(Integer merchantId)
    {
        return carGroupPurchaseMapper.listPurchaseByMerchantId(merchantId);
    }
}
